The phrase baptism by fire or baptism of fire, known in English since 1822, is a translation of the French phrase baptême du feu and is a reference to a soldier's first experience under fire in battle.
It originates from Matthew 3:11. Of this expression, J. H. Thayer commented: "to overwhelm with fire (those who do not repent), i.e., to subject them to the terrible penalties of hell" (1958, 94). W. E. Vine noted regarding the "fire" of this passage: "of the fire of Divine judgment upon the rejectors of Christ, Matt. 3:11 (where a distinction is to be made between the baptism of the Holy Spirit at Pentecost and the fire of Divine retribution)" (1991, 308). Arndt and Gingrich speak of the "fire of divine Judgment Mt. 3:11; Lk. 3:16" (1967, 737). Finally, as J. W. McGarvey observed, the phrase "baptize you ... in fire" cannot refer to Pentecost, because there was no "baptism of fire" on that day. Parted "tongues," which were merely "like as of fire ... sat upon" each of the apostles. Those brothers were not "overwhelmed with fire" on that occasion (1875, 38). (As quoted on http://www.christiancourier.com/articles/235-what-is-the-baptism-of-fire.)
Later it was used of martyrdom, especially by fire (e.g. Joan of Arc). Today, it has entered the common vernacular to describe anyone doing something "the hard way" for the first time, particularly if training is necessarily insufficient to fully prepare one for the experience (as is the case with battle).
(incomplete)